import React, { lazy } from 'react';
import { Redirect } from 'react-router-dom';
import Layout from '@/components/layout';
import Login from '@/views/Login';

const routes = [
    {
        path: '/',
        exact: true,
        render:() => {
          if(sessionStorage.getItem('info')){
            return <Redirect to={'/dynamic'} />;
          }else{
            return <Redirect to={'/login'} />;
          }
      }
    },
    {
      path: '/login',
      component: Login,
      exact: true,
    },
    // 党建动态模块
    {
      path: '/dynamic',
      component: Layout,
      breadcrumbName: '党建动态',
      children: [
            {
              path:'/dynamic',
              exact: true,
              render:() => {
                  return <Redirect to={'/dynamic/audit'} />;
              }
            },
            {
              path: '/dynamic/audit',
              component: lazy(() => import('@/views/Test')),
              title: '风采管理',
              breadcrumbName: '稿件审核管理',
            },
            {
              path: '/dynamic/article',
              component: lazy(() => import('@/views/Test')),
              title: '风采管理',
              breadcrumbName: '发布文章管理',
            },
            {
              path: '/dynamic/like',
              component: lazy(() => import('@/views/Test')),
              title: '风采管理',
              breadcrumbName: '点赞管理',
            },
            {
              path: '/dynamic/issue',
              component: lazy(() => import('@/views/Test')),
              title: '党校培训',
              breadcrumbName: '发布文章',
            },
            {
              path: '/dynamic/organization',
              component: lazy(() => import('@/views/Test')),
              title: '组织框架',
              breadcrumbName: '组织框架',
            },
      ]
    },
    // 党建服务模块
    {
      path: '/service',
      component: Layout,
      breadcrumbName: '党建服务',
      children: [
        {
          path:'/service',
          exact: true,
          render:() => {
              return <Redirect to={'/service/volunteer'} />;
          }
        },
        {
          path: '/service/volunteer',
          component: lazy(() => import('@/views/Test')),
          title: '志愿活动管理',
          breadcrumbName: '志愿者活动审核管理',
        },
        {
          path: '/service/sign',
          component: lazy(() => import('@/views/Test')),
          title: '志愿活动管理',
          breadcrumbName: '活动报名管理',
        },
        {
          path: '/service/lesson',
          component: lazy(() => import('@/views/Test')),
          title: '三会一课',
          breadcrumbName: '三会一课管理',
        },
        {
          path: '/service/summary',
          component: lazy(() => import('@/views/Test')),
          title: '三会一课',
          breadcrumbName: '纪要管理',
        },
        {
          path: '/service/message',
          component: lazy(() => import('@/views/Test')),
          title: '管理留言',
          breadcrumbName: '管理留言',
        },
        {
          path: '/service/vote',
          component: lazy(() => import('@/views/Test')),
          title: '投票调查',
          breadcrumbName: '投票调查',
        },
        {
          path: '/service/organization',
          component: lazy(() => import('@/views/Test')),
          title: '转组织关系',
          breadcrumbName: '转组织关系',
        },
        {
          path: '/service/theme',
          component: lazy(() => import('@/views/Test')),
          title: '主题党日管理',
          breadcrumbName: '主题党日管理',
        },
      ]
    },
    // 学习平台模块
    {
      path: '/study',
      component: Layout,
      breadcrumbName: '学习平台',
      children: [
        {
          path:'/study',
          exact: true,
          render:() => {
              return <Redirect to={'/study/problem'} />;
          }
        },
        {
          path: '/study/problem',
          component: lazy(() => import('@/views/Test')),
          title: '在线答题',
          breadcrumbName: '问题管理',
        },
        {
          path: '/study/record',
          component: lazy(() => import('@/views/Test')),
          title: '在线答题',
          breadcrumbName: '答题记录管理',
        },
        {
          path: '/study/sort',
          component: lazy(() => import('@/views/Test')),
          title: '在线答题',
          breadcrumbName: '问题分类',
        },
        {
          path: '/study/libary',
          component: lazy(() => import('@/views/Test')),
          title: '在线答题',
          breadcrumbName: '题库管理',
        },
      ]
    },
    // 基础管理模块
    {
      path: '/manage',
      component: Layout,
      breadcrumbName: '基础管理',
      children: [
        {
          path:'/manage',
          exact: true,
          render:() => {
              return <Redirect to={'/manage/part'} />;
          }
        },
        {
          path: '/manage/part',
          component: lazy(() => import('@/views/Test')),
          title: '党员管理',
          breadcrumbName: '党员管理',
        },
        {
          path: '/manage/user',
          component: lazy(() => import('@/views/Test')),
          title: '用户管理',
          breadcrumbName: '用户管理',
        },
        {
          path: '/manage/certification',
          component: lazy(() => import('@/views/Test')),
          title: '认证管理',
          breadcrumbName: '认证管理',
        },
        {
          path: '/manage/position',
          component: lazy(() => import('@/views/Test')),
          title: '职务管理',
          breadcrumbName: '职务管理',
        },
        {
          path: '/manage/collage',
          component: lazy(() => import('@/views/Test')),
          title: '学院管理',
          breadcrumbName: '学院管理',
        },
        {
          path: '/manage/announcement',
          component: lazy(() => import('@/views/Test')),
          title: '系统公告',
          breadcrumbName: '系统公告',
        },
        {
          path: '/manage/log',
          component: lazy(() => import('@/views/Test')),
          title: '操作日志',
          breadcrumbName: '操作日志',
        },
        {
          path: '/manage/account',
          component: lazy(() => import('@/views/Test')),
          title: '后台账号管理',
          breadcrumbName: '后台账号管理',
        },
      ]
    },
    {
      path: '/dynamic/*',
      component: lazy(() => import('@/components/NotFound')),
    },
    {
      path: '/service/*',
      component: lazy(() => import('@/components/NotFound')),
    },
    {
      path: '/study/*',
      component: lazy(() => import('@/components/NotFound')),
    },
    {
      path: '/manage/*',
      component: lazy(() => import('@/components/NotFound')),
    },
    {
      path: '*',
      component: lazy(() => import('@/components/NotFound')),
    },
];

export default routes;
